package com.hxd.otc.module.wallet.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.wallet.bean.TransferRecoderBean;
import com.hxd.otc.module.wallet.contract.TansferRecoderContact;
import com.hxd.otc.module.wallet.model.WalletModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;
import com.hxd.otc.utils.LogUtils;

import java.util.List;

/**
 * Created by lzy on 2018/8/6 0006.
 * description ${添加钱包联系人 Presenter}
 */
public class TransferRecoderPresenter extends BasePresenter<TansferRecoderContact.View> implements TansferRecoderContact.Presenter {

    private final WalletModel mModel;

    public TransferRecoderPresenter(TansferRecoderContact.View view) {
        super(view);
        mModel = WalletModel.getInstance();
    }

    @Override
    public void start() {

    }


    @Override
    public void getTransferRecoder(long page, long size) {
        mModel.getTransferRecoder(new BaseObserver<TransferRecoderBean>() {
            @Override
            public void onNext(@NonNull String msg, TransferRecoderBean bean) {
                LogUtils.e("onNext===" + bean.toString());
                doSetAdapter(bean.list);
                doShowNoMore();
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                LogUtils.e("onError===" + errMessage.toString());
                doShowNoMore();
                mView.showToast(errMessage);
                mView.onError(errType);
            }
        }, mView.<BaseBean<TransferRecoderBean>>bindAutoDispose(), page, size);
    }

    @Override
    public void doSetAdapter(List<TransferRecoderBean.TransferRecoderData> list) {
        mView.onSetAdapter(list);
        mView.onShowNoMore();
    }

    @Override
    public void doShowNoMore() {
        mView.onShowNoMore();
    }
}
